﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ipIncluirParamBenefCB.aspx.cs" Inherits="_includes__popup_ipIncluirParamBenefCB" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>
<%@ Register TagPrefix="uc1" TagName="HeadTag"  Src="~/_includes/HeadTag.ascx" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <!-- Includes -->
    <uc1:HeadTag ID="HeadTag1" runat="server" />    
    <title>Parâmetro de Benefício: Cesta Básica</title>
</head>
<body>
    <form id="form1" runat="server">
        <script type="text/javascript">
            function CloseAndRebind(args)
            {
                GetRadWindow().Close();
                GetRadWindow().BrowserWindow.refreshGrid(args);
            }
    		
            function GetRadWindow()
            {
                var oWindow = null;
                if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog
                else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;//IE (and Moz as well)
    				
                return oWindow;
            }

            function CancelEdit()
            {
                GetRadWindow().Close();
            }

            /* <![CDATA[ */

            function StopPropagation(e) {
                //cancel bubbling
                e.cancelBubble = true;
                if (e.stopPropagation) {
                    e.stopPropagation();
                }
            }

            function onDropDownClosing() {
                cancelDropDownClosing = false;
            }

            function onCheckBoxClick(chk) {
                var combo = $find("<%= rcbLocalidade.ClientID %>");
                //prevent second combo from closing
                cancelDropDownClosing = true;
                //holds the text of all checked items
                var text = "";
                //holds the values of all checked items
                var values = "";
                //get the collection of all items
                var items = combo.get_items();

                //enumerate all items
                for (var i = 0; i < items.get_count(); i++) {
                    var item = items.getItem(i);
                    //get the checkbox element of the current item
                    var chk1 = $get(combo.get_id() + "_i" + i + "_chk1");
                    if (chk1.checked) {
                        text += item.get_text() + ",";
                        values += item.get_value() + ",";
                    }
                }
                //remove the last comma from the string
                text = removeLastComma(text);
                values = removeLastComma(values);

                if (text.length > 0) {
                    //set the text of the combobox
                    combo.set_text(text);
                }
                else {
                    //all checkboxes are unchecked
                    //so reset the controls        
                    combo.set_text("")
                }
            }

            //this method removes the ending comma from a string
            function removeLastComma(str) {
                return str.replace(/,$/, "");
            }

            /* ]]> */
        </script>
        
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        
        <table width="99%" class="textoCZ_12B" align="right">
            <tr id="trMensagem" runat="server" visible="false">
                <td valign="middle" style="background-color:#FFFFAA; height:25px; width:100%">
                    &nbsp;&nbsp;<asp:Label ID="lblResultado" runat="server" Text="" Font-Names="Verdana" Font-Size="9"></asp:Label>
                </td>
            </tr>
            <tr>
                <td>
                    <div class="subTitulo_pagina">Dados de Parâmetro do Benefício: Cesta Básica</div>
                    <div class="espaco"></div>
                </td>
            </tr>
            <tr>
                <td>
                
                    <table class="textoCZ_12B">
                        <tr>
                            <td style="width: 230px">Localidade:</td>
                            <td>
                                <telerik:RadComboBox ID="rcbLocalidade" runat="server" Skin="Telerik" DataTextField="NomeCidade" DataValueField="IdCidade"
                                    Font-Names="Verdana" EmptyMessage="Selecione uma opção" HighlightTemplatedItems="true" AllowCustomText="true"
                                    Width="150px" OnClientDropDownClosed="onDropDownClosing">
                                    <ItemTemplate>
                                        <div onclick="StopPropagation(event)">
                                            <asp:CheckBox runat="server" ID="chk1" Checked="true" onclick="onCheckBoxClick(this)" />
                                            <asp:Label runat="server" ID="lblDescricao" AssociatedControlID="chk1"><%# Eval("NomeCidade")%></asp:Label>
                                        </div> 
                                    </ItemTemplate>
                                </telerik:RadComboBox>
                            </td>
                        </tr>
                        <tr>
                            <td>Validade (Data Inicial):</td>
                            <td>
                                <telerik:RadDatePicker ID="rdpDataInicial" runat="server" DateInput-DateFormat="dd/MM/yyyy" Font-Names="Verdana"></telerik:RadDatePicker>
                                <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator1" ControlToValidate="rdpDataInicial"
                                    InitialValue="" ErrorMessage="*" ValidationGroup="1" />
                            </td>
                        </tr>
                        <tr>
                            <td>Validade (Data Final):</td>
                            <td>
                                <telerik:RadDatePicker ID="rdpDataFinal" runat="server" DateInput-DateFormat="dd/MM/yyyy" Font-Names="Verdana"></telerik:RadDatePicker>
                                <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator6" ControlToValidate="rdpDataFinal"
                                    InitialValue="" ErrorMessage="*" ValidationGroup="1" />
                            </td>
                        </tr>
                    </table>
                
                </td>
            </tr>
            <tr>
                <td align="right">
                <br />
                <asp:Button ID="btnSalvar" runat="server" Text="Gravar" Width="110px" ValidationGroup="1" CausesValidation="true" onclick="btnSalvar_Click" />&nbsp;&nbsp;
                <asp:Button ID="btnLimpar" runat="server" Text="Limpar" Width="110px" onclick="btnLimpar_Click" />
                </td>
            </tr>
        </table>
    </form>
</body>
</html>
